import requests
def coordinates_to_boards(coord_str):
    size = 15  # 棋盘大小
    board = [['.' for i in range(size)] for i in range(size)]  # 初始化空棋盘
    letters = 'ABCDEFGHIJKLMNO'  # 字母对应的列索引

    boards = []
    # 遍历坐标字符串，每两位字符表示一个坐标
    for i in range(0, len(coord_str), 2):
        row_char = coord_str[i].upper()
        col_char = coord_str[i + 1].upper()

        if row_char in letters and col_char in letters:
            row = letters.index(row_char)
            col = letters.index(col_char)
        else:
            print(f"Invalid coordinates at index {i} and {i + 1}: {coord_str[i]}{coord_str[i + 1]}")
            continue

        if i // 2 % 2 == 0:
            board[row][col] = 'x'  # 黑棋
        else:
            board[row][col] = 'o'  # 白棋

        # 将当前棋盘状态转换为字符串（不包含换行符）
        board_str = ''.join([''.join(row) for row in board])
        boards.append(board_str)

    return boards



get_html = requests .get("http://183.175.12.27:8002/step_06")
coord_str=get_html.json()['questions']
boards = coordinates_to_boards(coord_str)

# 将每一步的棋盘图形表示用逗号分隔
ans = ','.join(boards)

# 提交结果到服务器
url = "http://183.175.12.27:8002/step_06"
response = requests.get(url, params={'ans': ans})

# 打印服务器响应
print(response.text)
